<template>
	<view class="ljapp my">
		<view class="header" :style="'background-image: url('+$base.cdn('/uploads/20220408/91d97cf1f274c3fd2892a8bed2d64c84.png')+');'">
			<u-navbar placeholder leftIconColor="#fff" titleStyle ="color:#fff;" title="我的" :bgColor="'rgba(22,188,236,'+navbarBgAlpha+')'"></u-navbar>
			<view class="outer">
				<view class="userinfo u-flex">
					<image class="avatar" :src="userInfo.headimgurl" mode="aspectFill"></image>
					<view class="inner">
						<view class="info u-flex u-flex-y-center">
							<view class="nickname">{{userInfo.nickname}}</view>
							<view class="phone">{{userInfo.mobile}}</view>
						</view>
						<view class="menu u-flex">
							<navigator url="/pagesL/my/health" class="item u-flex u-flex-xy-center">
								<image src="/static/lj/my/wallet.png" mode="aspectFill"></image>
								<view>我的健康金</view>
							</navigator>
							<navigator url="/pages/my/change" class="item u-flex u-flex-xy-center">
								<image src="/static/lj/my/group_572.png" mode="aspectFill"></image>
								<view>切换账号</view>
							</navigator>
						</view>
					</view>
					
					<image class="setting" src="/static/lj/my/icon_setting.png" mode="aspectFill" @click="gotosetting"></image>
				</view>
			</view>
		</view>
		
		<view class="content">
			<view class="card">
				<view class="title">我的订单</view>
				<view class="menu menu1 u-flex u-flex-wrap">
					<navigator hover-class="none" class="item" url="/pagesA/my/textList/textList">
						<image src="/static/lj/common/group_711.png" mode="widthFix"></image>
						<view class="tit">图文问诊订单</view>
					</navigator>
					<navigator hover-class="none" class="item" url="/pagesA/my/videoList/videoList">
						<image src="/static/lj/common/icon_department.png" mode="widthFix"></image>
						<view class="tit">视频问诊订单</view>
					</navigator>
					<navigator hover-class="none" class="item" url="/pagesL/my/signpage">
						<image src="/static/lj/common/icon_department-1.png" mode="widthFix"></image>
						<view class="tit">我的签约</view>
					</navigator>
					<navigator hover-class="none" class="item" url="/pagesL/my/reportpage">
						<image src="/static/lj/common/icon_abnormal.png" mode="widthFix"></image>
						<view class="tit">报告解读</view>
					</navigator>
					<navigator hover-class="none" class="item" url="/pagesA/drug/list">
						<view class="pic">
							<image src="/static/lj/my/icon_followmanagement.png" mode="widthFix"></image>
							<view class="badge" v-if="parseInt(userInfo.drug_can_pay_count||0)>0">{{userInfo.drug_can_pay_count||0}}</view>
						</view>
						<view class="tit">药品订单</view>
					</navigator>
				</view>
			</view>
			
			<view class="card">
				<view class="title">医疗服务</view>
				<view class="menu u-flex">
					<navigator url="/pagesL/check/list" class="item">
						<image src="/static/lj/my/group_729.png" mode="aspectFill"></image>
						<view class="tit">我的预约</view>
					</navigator>
					<navigator url="/pagesL/my/myReport" class="item">
						<image src="/static/lj/my/group_730.png" mode="aspectFill"></image>
						<view class="tit">我的报告</view>
					</navigator>
					<navigator hover-class="none" class="item" url="/pagesA/prescript/order3">
						<image src="/static/lj/my/group_623.png" mode="aspectFill"></image>
						<view class="tit">我的处方</view>
					</navigator>
					<navigator url="/pagesL/my/myDoctor" class="item">
						<image src="/static/lj/my/group_624.png" mode="aspectFill"></image>
						<view class="tit">我的医生</view>
					</navigator>
				</view>
			</view>
			
			<view class="card">
				<view class="title">常用工具</view>
				<view class="menu menu2 u-flex u-flex-wrap">
					<navigator hover-class="none" class="item" url="/pagesL/my/couponList">
						<image src="/static/lj/my/my-icon-1.png" mode="aspectFill"></image>
						<view class="tit">我的优惠券</view>
					</navigator>
					<navigator hover-class="none" class="item" url="/pagesA/my/comment">
						<image src="/static/lj/my/my-icon-2.png" mode="aspectFill"></image>
						<view class="tit">我的评论</view>
					</navigator>
					<view class="item">
						<image src="/static/lj/my/my-icon-3.png" mode="aspectFill"></image>
						<view class="tit">我的积分</view>
					</view>
			
					<button class="item" open-type="share">
						<image src="/static/lj/my/my-icon-4.png" mode="aspectFill"></image>
						<view class="tit">分享好友</view>
					</button>
					<navigator hover-class="none" class="item" url="/pagesA/my/jzrgl">
						<image src="/static/lj/my/my-icon-5.png" mode="aspectFill"></image>
						<view class="tit">就诊人管理</view>
					</navigator>
					<navigator hover-class="none" class="item" url="/pagesA/my/address">
						<image src="/static/lj/my/my-icon-6.png" mode="aspectFill"></image>
						<view class="tit">我的地址</view>
					</navigator>
					<navigator hover-class="none" class="item" url="/pages/home/platformProtocol">
						<image src="/static/lj/my/my-icon-7.png" mode="aspectFill"></image>
						<view class="tit">平台协议</view>
					</navigator>
					<button class="item" open-type="contact">
						<image src="/static/lj/my/my-icon-8.png" mode="aspectFill"></image>
						<view class="tit">客服中心</view>
					</button>
				</view>
			</view>
			
			<navigator hover-class="none" class="item" url="/pages/message/log" style="text-align: center;margin-top: 50rpx;font-size: 32rpx;color:#666;">IM日志</navigator>
			<view class="btn-fillet btn-logout" @click="Onlogout">退出登录</view>
		</view>
		
		<ComTabBar :selected="3"></ComTabBar>
	</view>

</template>

<script>
	import ComTabBar from '@/components/ComTabBar.vue';
	export default {
		components: {
			ComTabBar
		},
		data() {
			return {
				navbarBgAlpha: 0,
				userInfo: {}, //用户信息
			}
		},
		onLoad() {
			uni.hideTabBar()
		},
		onShow() {
			this.Oninfo()
		},
		onPageScroll: function(e) {
			var a = e.scrollTop/80
			this.navbarBgAlpha = a>1?1:a
		},
		// 自定义此页面的转发给好友(已经有全局的分享方法，此处会覆盖全局)
		onShareAppMessage(res) {
			var data = {path: '/pages/home/index?spuid='+this.$store.state.user.uid}, shareConfig = this.$store.state.shareConfig
			console.log(shareConfig)
			if(shareConfig.title) data.title = shareConfig.title
			if(shareConfig.image) data.imageUrl = this.$base.cdn(shareConfig.image)
			return data
		},
		// 自定义页面的分享到朋友圈
		// onShareTimeline(res) {
		// 	var data = {path: '/pages/home/index?spuid='+(userInfo.id||0)}, shareConfig = this.$store.state.shareConfig
		// 	if(shareConfig.title) data.title = shareConfig.title
		// 	if(shareConfig.image) data.imageUrl = this.$base.img(shareConfig.image)
		// 	return data
		// },
		methods: {
			Oninfo() {
				let that = this
				
				this.$Http({
					url: 'getUserInfo',
					type: 'POST',
					data: {}
				}).then(res => {
					if (res.code == 1) {
						this.userInfo = res.data
					}
				})
			},
			//退出登录
			Onlogout() {
				this.$store.dispatch('logout')
				uni.clearStorage();
				// this.userInfo = {}
				// this.Oninfo()
				
				let pages = getCurrentPages()
				let beforePage = pages[pages.length - 1].route;
				let Pageoptions = pages[pages.length - 1].options
				if (Pageoptions == {}) {
					beforePage = beforePage
				} else {
					let num = 0
					for (let key in Pageoptions) {
						num++
						if (num > 1) {
							beforePage = beforePage + '&' + key + '=' +
								Pageoptions[key]
						} else {
							beforePage = beforePage + '?' + key + '=' +
								Pageoptions[key]
						}
					}
				}
				uni.$store.commit('Onvuexurl', beforePage)
				uni.redirectTo({
					url: '/pagesA/common/Signin'
				});
			},
			
			gotosetting(){
				uni.navigateTo({
					url: '/pagesL/my/setting'
				})
			},
		}
	}
</script>

<style lang="less">
	@import '@/pages/style.less';
	page{
		padding-bottom: constant(safe-area-inset-bottom);
		padding-bottom: env(safe-area-inset-bottom);
	}
</style>
